package com.doxiaopu.students.mapper;

import com.doxiaopu.students.user.entity.User;
import com.doxiaopu.students.user.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

@SpringBootTest
public class UserMapperTestCase {
    @Autowired(required = false)
    private UserMapper userMapper;

    @Test
    public void addNewUser() {
        Date now = new Date();
        User user = new User();
        user.setUsername("root6");
        user.setPassword("1234");
        user.setGender(1);
//        user.setId(18);
        user.setPhone("13883258584");
        user.setNickname("小王");
        user.setSalt("Hello,MD5!");
        user.setIsDelete(0);
//        user.setAvatar("男");
        user.setCreatedUser("Admin");
        user.setModifiedUser("Admin");
        user.setCreatedTime(now);
        user.setModifiedTime(now);
        System.err.println("user:" + user);
//        System.err.println("userMapper:" + userMapper);
        Integer rows = userMapper.addNewUser(user);
        System.err.println("rows:" + rows);
    }

    @Test
    public void findBalance() {
//        String TEST = UUID.randomUUID().toString().replaceAll("-", "");
//        String TEST = UUID.randomUUID().toString();
        Integer tes = ThreadLocalRandom.current().nextInt(1, 99999 + 1);
//        User user = userMapper.getBalanceByTUserId("466f6fe7-3a32-406b-9698-97869d57d63e");
        System.err.println("tes:" + tes);
    }
    @Test
    public void updateBalance() {
        Date now = new Date();
        User user = new User();
        user.setBalance(10);
        user.setTUserId("466f6fe7-3a32-406b-9698-97869d57d63e");
        user.setModifiedUser("Admin");
        user.setModifiedTime(now);

        System.err.println("user:" + user);
//        System.err.println("userMapper:" + userMapper);
        Integer rows = userMapper.updateBalance(user);
        System.err.println("rows:" + rows);
    }

}
